package com.jiqiu.controller;


import com.jiqiu.entity.Boss;
import com.jiqiu.pojo.Result;
import com.jiqiu.service.IBossService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.apache.ibatis.annotations.Delete;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * BOSS表 前端控制器
 * </p>
 *
 * @author jiqiu
 * @since 2024-07-28
 */
@Tag(name = "BOSS相关接口")
@RestController
@RequestMapping("/boss")
@RequiredArgsConstructor
public class BossController {
    private static final Logger log = LoggerFactory.getLogger(BossController.class);
    private final IBossService iBossService;

    @Operation(summary = "新增BOSS接口")
    @PostMapping
    public Result<String> saveBoss(@RequestBody @ApiParam("BOSS") Boss boss) {
        log.info("新增BOSS数据中......");
        iBossService.save(boss);
        return Result.success("新增成功");
    }

    @Operation(summary = "删除单个BOSS操作")
    @DeleteMapping
    public Result<String> deleteById(@ApiParam("删除id") Long id) {
        log.info("正在删除数据中......删除id为:{}", id);
        iBossService.removeById(id);
        return Result.success("删除成功");
    }


    @Operation(summary = "批量删除BOSS操作")
    @DeleteMapping("/ids")
    public Result<String> deleteBatch(@RequestParam List<Long> ids) {
        log.info("批量删除数据中......删除的id为:{}", ids);
        iBossService.removeByIds(ids);
        return Result.success("删除成功");
    }


    @Operation(summary = "修改BOSS操作")
    @PutMapping
    public Result<String> update(@RequestBody Boss boss) {
        log.info("修改数据中......修改的数据为:{}", boss);
        return Result.success("修改成功");
    }
    @Operation(summary = "查看单个BOSS")
    @GetMapping("/{id}")
    public Result<Boss> getMessageById(@PathVariable Long id) {
        Boss boss = iBossService.getById(id);
        return Result.success(boss);
    }


}
